from wxpyview.ui.component.common.basewidget import *

class MenuBar(Widget):
    def _getParentParam(self, meta_widget):
        stopping_point = ['Frame', 'MDIParentFrame'] 
        return ComponentLibrary.findFirstMatchedAncestor(meta_widget, stopping_point)
    
    def _setParams(self, meta_widget):
        dom = meta_widget.getDOM()
        if not dom:
            raise IOException
        
        self.params["parent"] = self._getParentParam(meta_widget)
        
    def create(self, meta_widget):
        self._setParams(meta_widget)
        
        menuBar = wx.MenuBar()
        self.params["parent"].SetMenuBar(menuBar)
        
        return menuBar